﻿using System.Collections.Generic;

namespace Wpf_Client.Model
{
    public class SeverModel : ModelBase
    {
        private string _targetId;
        private string _targetPassword;

        public string TargetId
        {
            get
            {
                return _targetId;
            }

            set
            {

                if (value == _targetId) return;
                _targetId = value;
                OnPropertyChanged("TargetIdShow");
                OnPropertyChanged("TargetId");
            }
        }

        public string TargetIdShow => ReformatNovaid(_targetId);

        private static string ReformatNovaid(string novaid)
        {
            var charArray = novaid.ToCharArray();
            var newCharList = new List<char>();
            for (var i = 0; i < charArray.Length; i++)
            {
                if (i % 3 == 0 && i != 0)
                {
                    newCharList.Add(' ');
                }
                newCharList.Add(charArray[i]);

            }
            return new string(newCharList.ToArray());
        }
        public string TargetPassword
        {
            get
            {
                return _targetPassword;
            }

            set
            {
                if (value == _targetPassword) return;
                _targetPassword = value;
                OnPropertyChanged("TargetPassword");
            }
        }
    }
}
